package com.example.demo;

import lombok.extern.slf4j.Slf4j;
import org.noear.solon.net.websocket.WebSocket;
import org.noear.solon.net.websocket.WebSocketListener;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * @author airhead
 */
@Slf4j
public class DemoBaseWebSocketListener implements WebSocketListener {

  @Override
  public void onOpen(WebSocket socket) {
  }

  @Override
  public void onMessage(WebSocket socket, String rawMsg) throws IOException {
    log.info("onMessage: {}", rawMsg);
    socket.send(rawMsg);
  }

  @Override
  public void onMessage(WebSocket socket, ByteBuffer binary) throws IOException {
  }

  @Override
  public void onClose(WebSocket socket) {
  }

  @Override
  public void onError(WebSocket socket, Throwable error) {
  }

}
